import { Component, OnInit } from '@angular/core';
import { ReportService } from '../../report.service';
import { MenuItem } from 'primeng/api';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { switchMap } from 'rxjs/operators';

@Component({
  templateUrl: './report-standard.component.html',
  styleUrls: ['./report-standard.component.scss']
})
export class ReportStandardComponent implements OnInit {
  reportId: number;
  report: any;

  constructor(
    private route: ActivatedRoute,
    private reportService: ReportService) {
  }

  ngOnInit() {
    //初始化查询条件
    this.route.paramMap.pipe(
      switchMap((params: ParamMap) => {
        this.reportId = +params.get('id');
        return this.reportService.loadReport(this.reportId);
      })
    ).subscribe(report => this.report = report);
  }
}
